package io.gitee.chearnee.fw.web.exception;

import io.gitee.chearnee.fw.common.model.IResultCode;
import io.gitee.chearnee.fw.common.model.vo.ResultCode;
import lombok.Getter;

import java.io.Serial;

@Getter
public class ApiException extends RuntimeException {

    @Serial
    private static final long serialVersionUID = 3167080770136567141L;
    private final IResultCode resultCode;
    private final String message;


    public ApiException(String message) {
        this(ResultCode.FAILED, message);
    }

    public ApiException(IResultCode resultCode) {
        this(resultCode, resultCode.getMessage());
    }

    public ApiException(IResultCode resultCode, String message) {
        super(message);
        this.message = message;
        this.resultCode = resultCode;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
